import { http } from '@/utils/http'
import type { postResult, postPrames, configType, voteResult, userInfo  } from '@/types/userInfo'


// 登录
 export const login = (data: { userid: string}) => {
  return http<userInfo>({
    method: 'POST',
    url: '/api/index/login',
    data
  })
}


/**
 * 获取标签
 */
export const getPosts = (data:postPrames) => {
  return http<postResult>({
    method: 'GET',
    url: '/api/index/getPosts?page='+data.page+'&limit='+data.limit,
    data
  })
}

// 获取配置
 export const getConfig = () => {
  return http<configType>({
    method: 'GET',
    url: '/api/index/getConfig',
  })
}

// 点赞
export const like = (id:number) => {
  return http<voteResult>({
    method: 'POST',
    url: '/api/index/like',
    data: { id }
  })
}


// adv点赞
export const advLike = () => {
  return http<userInfo>({
    method: 'POST',
    url: '/api/index/voteAdv'
  })
}

